package com.hr.utils;

public class UserContext {
    private static final ThreadLocal<Long> userIdHolder = new ThreadLocal<>();
    private static final ThreadLocal<Integer> roleIdHolder = new ThreadLocal<>();

    public static void setUserId(Long userId) {
        userIdHolder.set(userId);
    }

    public static void setRoleId(Integer roleId) {
        roleIdHolder.set(roleId);
    }

    public static Long getUserId() {
        return userIdHolder.get();
    }

    public static Integer getRoleId() {
        return roleIdHolder.get();
    }

    public static void remove() {
        userIdHolder.remove();
        roleIdHolder.remove();
    }
}
